package com.home.zcym.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName: CommonUtil
 * @Description: 公共工具类
 */
public class CommonUtil {
  private CommonUtil() {}

  /**
   * warppreResponse: 包装响应信息
   * @Date: 2019/07/22 上午10:51
   * @param: key
   * @param: data
   */
  public static Map<String, Object> warppreResponse(String key, Object data) {
    Map<String, Object> result = new HashMap<String, Object>();
    result.put(key + "_response", data);
    return result;
  }

  public static Integer getNdaysBeforeNow(int n) {
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DAY_OF_MONTH, -n);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
    return Integer.parseInt(sdf.format(cal.getTime()));
  }
}
